{extend name="index_layout"/}
{block name="main"}
<div class="layui-card">
    <div class="layui-card-body">
        <button id="checkUpdateBtn" class="layui-btn">检查更新</button>
        <blockquote class="layui-elem-quote text" style="font-size: 16px; margin: 10px 0;">
            <span>{$version|raw}</span>，
            <span {if $is_update} style="color: red" {/if}>{$latest_version|raw}</span>
        </blockquote>
        <div class="layui-row layui-col-space10">
            <div class="layui-col-lg6 layui-col-md12">
                <table id="versionTable" class="layui-table">
                    <thead>
                    <col width="150"/>
                    <col/>
                    <col width="200"/>
                    <tr>
                        <th>版本号</th>
                        <th>更新内容</th>
                        <th>发布日期</th>
                    </tr>
                    </thead>
                    <tbody>
                    {volist name="lists" id="vo"}
                    <tr>
                        <td>{$vo.version}</td>
                        <td>{$vo.content|raw}</td>
                        <td>{$vo.create_time}</td>
                    </tr>
                    {/volist}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
    // layui.use(['element'], function () {
    //
    // });
    $(function () {
        $('#checkUpdateBtn').click(function () {
            layer.open({
                type: 0,
                title: false,
                content: '正在检查更新...',
                closeBtn: 0,
            });
            var index = layer.load(0);
            $.ajax({
                url: '{:url("admin/version/update")}',
                type: 'post',
                dataType: 'json',
                success: function (res) {
                    layer.closeAll();
                    if (res.code !== -1) {
                        notice.success(res.msg)
                        setTimeout(function () {
                            location.reload()
                        }, 1500)
                    } else {
                        notice.error(res.msg)
                    }
                }
            })
        })
    });
</script>
{/block}
